<template>
  <div>
    <van-nav-bar title="收货地址" fixed>
      <div class="left_arrow" @click="()=>{ $router.go(-1) }" slot="left">
        <van-icon name="arrow-left"/>
        <span>返回</span>
      </div>
    </van-nav-bar>
    <!-- 地址列表 -->
    <div class="addressList"></div>
    <van-address-list
      v-model="chosenAddressId"
      :list="addressList"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit"
    />
    <!-- <van-nav-bar title="黑马优购" left-text="返回" fixed left-arrow/> -->
    <!-- <div class="addAdress">新增地址</div> -->
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  data() {
    return {
      chosenAddressId: "1",
      list: [
       
      ]
    };
  },
  methods: {
    onAdd() {
      this.$router.push("/address_add");
    },
    onEdit(item) {
      console.log(item);
      this.$store.commit('editAddress',item.id)
      this.$router.push("/address_edit");
      window.sessionStorage.setItem('editId',item.id)
    }
  },
  computed:{
    ...mapState(['addressList'])
  }
};
</script>

<style lang="less" scoped>
.addressList {
  margin-top: 46px;
}
</style>